const tree = [{
  name: "根节点", type: "文件夹", children: [{
    name: "文件夹1", type: "文件夹", children: [{
      name: "文件夹1-1", type: "文件夹", children: [{
        name: "文件夹1-1-1", type: "文件夹", children: [{
          name: "文件1-1-1-1", type: "文件", size: "10KB", lastModified: "2025-01-10",
        }, {
          name: "文件1-1-1-2", type: "文件", size: "20KB", lastModified: "2025-01-09",
        },],
      }, {
        name: "文件1-1-2", type: "文件", size: "25KB", lastModified: "2025-01-08",
      },],
    }, {
      name: "文件1-2", type: "文件", size: "15KB", lastModified: "2025-01-07",
    },],
  }, {
    name: "文件夹2", type: "文件夹", children: [{
      name: "文件夹2-1", type: "文件夹", children: [{
        name: "文件2-1-1", type: "文件", size: "30KB", lastModified: "2025-01-06",
      }, {
        name: "文件2-1-2", type: "文件", size: "40KB", lastModified: "2025-01-05",
      },],
    }, {
      name: "文件夹2-2", type: "文件夹", children: [{
        name: "文件2-2-1", type: "文件", size: "50KB", lastModified: "2025-01-04",
      }, {
        name: "文件2-2-2", type: "文件", size: "60KB", lastModified: "2025-01-03",
      },],
    },],
  }, {
    name: "文件3", type: "文件", size: "70KB", lastModified: "2025-01-02",
  },],
}];

const treeData = [{
  id: "p1", title: '广东', children: [{
    id: "p1-1", title: '广州',
  }]
}, {
  id: "p2", title: "四川", children: [{
    id: "p2-1", title: "成都", children: [{
      id: "p2-1-1", title: "高新区",
    }]
  }, {
    id: "p2-2", title: "德阳"
  }, {
    id: "p2-3", title: "绵阳"
  }]
}]

function treeToList(tree, result = []) {
  for (const item of tree) {
    const { children, ...rest } = item
    if (children?.length) {
      treeToList(children, result)
    }
    result.push(rest)
  }
  return result
}

const list1 = treeToList(tree)
const list2 = treeToList(treeData)

console.log(list1, list2)
























